//
//  DB.m
//  哎游
//
//  Created by 康守帅 on 15-1-13.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "DB.h"

static sqlite3 *dbPoint = nil;

@implementation DB

+ (sqlite3 *)openDB
{
    if (dbPoint) {
        return dbPoint;
    }
    NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path = [array objectAtIndex:0];
    path = [NSString stringWithFormat:@"%@/UserDataBase.rdb", path];
    
    NSFileManager *file = [NSFileManager defaultManager];
    if (![file fileExistsAtPath:path]) {
        NSString *source = [[NSBundle mainBundle] pathForResource:@"UserDataBase" ofType:@"rdb"];
        [file copyItemAtPath:source toPath:path error:nil];
    }
    NSLog(@"111111111%@", path);
    sqlite3_open([path UTF8String], &dbPoint);
    return dbPoint;
}





@end
